package by.jabbby.service;

import java.util.ArrayList;

public class EventsManager {
	private final ArrayList<IJabberServiceHandler> handlers = new ArrayList<IJabberServiceHandler>();
	private static final EventsManager em = new EventsManager();

	public static EventsManager getEventsManager() {
		return em;
	}

	public void addEventHandler(IJabberServiceHandler evHandler) {
		handlers.add(evHandler);
	}

	public boolean removeEventHandler(IJabberServiceHandler evHandler) {
		return handlers.remove(evHandler);
	}
	
	public void sendEvent(Event event){
		for (IJabberServiceHandler handler : handlers) {
			handler.event(event);
			
		}
	}

}
